    //
//  timelineViewController.m
//  ephemera
//
//  Created by Anna on 5/22/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "timelineViewController.h"


@implementation timelineViewController

@synthesize timelineSlider, ephemeronLabel, ephemeronImageView, ephemeronTitleLabel, blurbTextView;// UI Elements
@synthesize yearDict, iDict, blurbDict; // from app delegate

-(IBAction)moveSlider{
	//int year = [[NSNumber numberWithFloat:[timelineSlider value]] intValue];
	int range = maxYear - minYear;
	int newRange = [[NSNumber numberWithFloat:([timelineSlider value] * range)] intValue];
	int year = newRange + minYear;	
	NSArray *results = [yearDict allKeysForObject:[NSNumber numberWithInt:year]];	
	NSLog(@"the year: %d", year);
	NSLog(@"results array: %@", results);
	NSString *headline = [results lastObject];
	NSLog(@"the headline: %@", headline);
	ephemeronTitleLabel.text = headline;
	blurbTextView.text = [blurbDict objectForKey:headline];
	
	NSString *imgName = [iDict objectForKey:headline];
	UIImage *img = [UIImage imageNamed:imgName];
	[ephemeronImageView setImage:img];
	
	
	[ephemeronLabel setText:[NSString stringWithFormat:@"Year Chosen: %d", year]];
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	NSLog(@"in view did load");
	[super viewDidLoad];
	minYear = 1800;
	maxYear = 2010;
	[ephemeronLabel setText:@"Year Chosen: 1894"];
	[ephemeronTitleLabel setText:@""];
	[timelineSlider setValue:0.5f ];
	NSLog(@" the year dictionary: %@", yearDict);

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
